home *** CD-ROM | disk | FTP | other *** search
- Path: cville-srv.wam.umd.edu!jsquires
- From: jsquires@wam.umd.edu (jeffrey d squires)
- Newsgroups: comp.lang.c
- Subject: Limit on #bytes inside of struct?
- Date: 9 Feb 1996 22:01:20 GMT
- Organization: University of Maryland College Park
- Message-ID: <4fgg7g$r36@cville-srv.wam.umd.edu>
- NNTP-Posting-Host: rac4.wam.umd.edu
- X-Newsreader: TIN [version 1.2 PL0]
-
- I previously wrote:
- >
- >I have the following:
- >
- >typedef struct {
- > int zero;
- > int one;
- > int two;
- > int three;
- > int four;
- > int five;
- > int six;
- > int seven_or_more;
- >} hist_type;
- >
- >hist_type histogram;
- >int num=2;
- >
- >histogram.zero = 0;
- >histogram.one = 0;
- >histogram.two = 0;
- >histogram.three = 0;
- >histogram.four = 0; /* at this point, value of num changes from 2 to 0
- !!!*/
- >
- >Is there a limit on the number of bytes allowed inside of a struct?
- >I am positive that the value of num changes from 2 before the last
- >assignment to 0 after it. Any ideas? Is this a bug in gcc? Unix?
- >
- >This is completely crazy!
- >
-
-
- What I left out was that I tried to do this:
-
- #define NUM_PASSES 3
-
-
- .
- .
- .
- .
- .
-
-
-
-
- hist_type histogram[NUM_PASSES]; /* BIIIIIG MISTAKE */
-
- I tried to have the above example be simple, but it appears that I left
- out the part that contained the problem. I guess that you can;t
- declare an array with the size defined by #define. I had to do:
-
- hist_type * histogram;
- histogram = .... malloc(NUM_PASSES * ......
-
- That worked, and my problem is solved. Thanks everyone for responding
- Sorry to be unclear.
-
- Jeff Squires
- jsquires@wam.umd.edu
-
-